/*********************************************************************************
 *FileName:  nsuc16xx_rcc.c
 *Version:  V1.0
 *Date: 2023-04-07
 ****************************************Includes***********************************/
#include "nsuc16xx_rcc.h"

/***************************************Variables***********************************/

/***************************************Functions***********************************/
void SYSCTRL_Unlock(void)
{
    SYSCTRL->LKKEYR = SYSCTRL_UNLOCK_KEY;
}

void RCC_SystemClockControl(uint32_t RCC_ClockSource, FunctionalState NewState)
{
    if (NewState != DISABLE)
    {
        SYSCTRL->SCCR |= RCC_ClockSource;
    }
    else
    {
        SYSCTRL->SCCR &= ~RCC_ClockSource;
    }
}

void RCC_APBPeriphClockCmd(uint32_t RCC_APBPeriph, FunctionalState NewState)
{

    if (NewState != DISABLE)
    {
        SYSCTRL->APBCGR |= RCC_APBPeriph;
    }
    else
    {
        SYSCTRL->APBCGR &= ~RCC_APBPeriph;
    }
}

void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState)
{

    if (NewState != DISABLE)
    {
        SYSCTRL->AHBCGR |= RCC_AHBPeriph;
    }
    else
    {
        SYSCTRL->AHBCGR &= ~RCC_AHBPeriph;
    }
}

/***************************************END OF FILE*********************************/
